package edu.scau.misp.backend_module.service.impl;

import edu.scau.misp.backend_module.domain.Category;
import edu.scau.misp.backend_module.mapper.CategoryMapper;
import edu.scau.misp.backend_module.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CategoryServiceImpl implements ICategoryService {


    @Autowired
    private CategoryMapper categoryMapper;













    //    ---------------------------------------以下是基础CRUD------------------------------------------


    /**
     * 根据ID查询分类Category
     *
     * @param categoryId 分类ID
     * @return 返回一个Category对象
     */
    @Override
    public Category getCategoryById(Long categoryId) {
        return categoryMapper.getCategoryById(categoryId);
    }

    /**
     * 查询所有分类
     * @return 返回泛型为Category的集合
     */
    @Override
    public List<Category> listAllCategory() {
        return categoryMapper.listAllCategory();
    }

    /**
     * 查询分类列表
     *
     * @param category 查询参数
     * @return 对象集合
     */
    @Override
    public List<Category> selectCategoryList(Category category) {
        return categoryMapper.selectCategoryList(category);
    }

    /**
     * 新增分类
     *
     * @param category
     * @return 影响记录数
     */
    @Override
    public int insertCategory(Category category) {
        return categoryMapper.insertCategory(category);
    }

    /**
     * 修改分类
     *
     * @param category
     * @return 影响记录数
     */
    @Override
    public int updateCategory(Category category) {
        return categoryMapper.updateCategory(category);
    }

    /**
     * 删除分类
     *
     * @param categoryId 主键
     * @return 影响记录数
     */
    @Override
    public int deleteCategoryById(Long categoryId) {
        return categoryMapper.deleteCategoryById(categoryId);
    }
}
